package com.kechen.servlet;

import com.kechen.dao.EmpDao;
import com.kechen.pojo.Employee;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//@WebServlet("/getAll")
public class GetServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        EmpDao dao=new EmpDao();
        List<Employee> emps= dao.findEmps();
        request.setAttribute("emps", emps);
        System.out.println("aaaaaaaaaaaaaaaa");
        //转发
        request.getRequestDispatcher("a.jsp").forward(request, response);
//        response.getWriter().write("你好");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

}

